<%-- 
    Document   : template
    Created on : 30/10/2012
    Author     : Volodymyr Lavrynovych <volodya.lavrynovych@gmail.com>
--%>

<%@page import="mygang.controller.AbstractController"%>
<%@page import="mygang.helper.ApplicationContentHelper"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="mg" tagdir="/WEB-INF/tags"%>
<%
    String title = "Manage templates";
    ApplicationContentHelper helper = new ApplicationContentHelper(request);
%>
<!DOCTYPE html>
<html>
    <head>
        <%=helper.getJQueryDataTable()%>
        <mg:import file="model/manage.js"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><%=title%></title>
        <script type="text/javascript">
            $(document).ready(function(){
                window.model = new ManageModel({
                    title: '<%=title%>',
                    itemName: 'Template',
                    actions:{
                        url: '<%=AbstractController.MANAGE_TEMPLATE%>/'
                    },
                    tableOptions: {
                        prepareRow: function(template){
                            var $row = $('<tr>').attr('id', template.id);
                            var $name = $('<td>').text(template.name);
                            var $regex = $('<td>').text(template.regex);
                            var $mask = $('<td>').text(template.mask);
                            var $elementTag = $('<td>').text(template.element.tag)
                            var $elementType = $('<td>').text(template.element.type)

                            return $row
                                .append($name)
                                .append($regex)
                                .append($mask)
                                .append($elementTag)
                                .append($elementType);
                        }
                    }
                });
            })
        </script>
    </head>
    <body>
        <div class='target'>
            <table id="dataTable">
                <thead>
                    <tr class="table-caption">
                        <th rowspan="2" style="width: 30%; vertical-align: middle;">Name</th>
                        <th rowspan="2" style="width: 30%; vertical-align: middle;">RegEx</th>
                        <th rowspan="2" style="width: 15%; vertical-align: middle;">Mask</th>
                        <th colspan="2" style="width: 25%; text-align: center">Element</th>
                    </tr>
                    <tr class="table-caption">
                        <th>Tag</th>
                        <th>Type</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </body>
</html>
